/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "HDRTB_SUBBACIA_RIO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SubbaciaRio.findAll", query = "SELECT s FROM SubbaciaRio s"),
    @NamedQuery(name = "SubbaciaRio.findBySbrId", query = "SELECT s FROM SubbaciaRio s WHERE s.sbrId = :sbrId"),
    @NamedQuery(name = "SubbaciaRio.findRioBySubbacia", query = "SELECT s.sbrRioCd FROM SubbaciaRio s WHERE s.sbrDnsCd = :sbrDnsCd ORDER BY s.sbrRioCd.rioNm"),
    @NamedQuery(name = "SubbaciaRio.findSubbaciaByRio", query = "SELECT s.sbrDnsCd FROM SubbaciaRio s WHERE s.sbrRioCd = :sbrRioCd")
        
})
public class SubbaciaRio implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "SBR_ID")
    private BigDecimal sbrId;
    @JoinColumn(name = "SBR_RIO_CD", referencedColumnName = "RIO_CD")
    @ManyToOne
    private Rio sbrRioCd;
    @JoinColumn(name = "SBR_DNS_CD", referencedColumnName = "DNS_CD")
    @ManyToOne
    private Subbacia sbrDnsCd;

    public SubbaciaRio() {
    }

    public SubbaciaRio(BigDecimal sbrId) {
        this.sbrId = sbrId;
    }

    public BigDecimal getSbrId() {
        return sbrId;
    }

    public void setSbrId(BigDecimal sbrId) {
        this.sbrId = sbrId;
    }

    public Rio getSbrRioCd() {
        return sbrRioCd;
    }

    public void setSbrRioCd(Rio sbrRioCd) {
        this.sbrRioCd = sbrRioCd;
    }

    public Subbacia getSbrDnsCd() {
        return sbrDnsCd;
    }

    public void setSbrDnsCd(Subbacia sbrDnsCd) {
        this.sbrDnsCd = sbrDnsCd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sbrId != null ? sbrId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SubbaciaRio)) {
            return false;
        }
        SubbaciaRio other = (SubbaciaRio) object;
        if ((this.sbrId == null && other.sbrId != null) || (this.sbrId != null && !this.sbrId.equals(other.sbrId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return ""+this.sbrId;
    }
    
}
